import { ApiCall } from "tsrpc";
import {ReqLook, ResLook } from "../../../../shared/master/body/skill/PtlLook";
import {  template } from "../../../../shared/master/MsgAction";
import { player } from "../../../../model/fight/body/player";

export default async function (call: ApiCall<ReqLook, ResLook>) {
    call.succ({})
    let user = call.req._player as player;
    let sks = user.getAllSkills()
    let sk = sks[call.req.idx - 1];
    if (call.req.idx != 0) {
        if (!sk) {
            user.sendMsg(template.default, `你自身没有ID为[${call.req.idx}]的技能`)
            return;
        }
    } else {
        let _idx = sks.findIndex((item) => {
            return item.rename == call.req.name;
        })
        if (_idx == -1) {
            user.sendMsg(template.default, `你自身没有ID为[${call.req.idx}]的技能`)
            return;
        }
        sk = sks[_idx];
    }
    user.sendMsg(template.skill_info, sk.get_panel(user))
}